﻿<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>中标单位查询统计</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="/plugins/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="/plugins/layuiadmin/style/admin.css" media="all">
</head>
<body>
  <div class="layui-fluid">
    <div class="layui-card">
      <div class="layui-card-body">
        <div style="padding-bottom: 10px;">
          <button class="layui-btn layuiadmin-btn-list" data-type="refresh"><i class="layui-icon layui-icon-refresh"></i>刷新</button>
          <div class="layui-form" lay-filter="dds-search-form" id="dds-search-form" style="float:right">
            <div class="layui-inline">
            <input type="text" class="layui-input" id="starttime" name="starttime" style="width:150px;" autocomplete="off" readonly="readonly" placeholder="开始时间">
            </div>
            <div class="layui-inline">
            <input type="text" class="layui-input" id="endtime" name="endtime" style="width:150px;" autocomplete="off" readonly="readonly" placeholder="结束时间">
            </div>
            <div class="layui-input-inline">
            <select name="typeid" id="typeid">
                <option value="">选择项目类型</option>
            </select>
            </div>
            <div class="layui-inline">
             <input class="layui-input" name="keyword" id="keyword" style="width:200px;" placeholder="项目名称、单位名称或采购人">
            </div>
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="btn_search"><i class="layui-icon layui-icon-search"></i>查询</button>
          </div>
        </div>
        <table id="dds-list" lay-filter="dds-list"></table>
        <script type="text/html" id="tpl_lunci">
            第{{d.lun}}轮,第{{d.ci}}次
        </script>
        <script type="text/html" id="table-content-list">
          <a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="queren"><i class="layui-icon layui-icon-edit"></i>确认表</a>
        </script>
      </div>
    </div>
  </div>
  <script src="/plugins/layui/layui.js"></script> 
  <script>
  layui.config({
    base: '/plugins/layuiadmin/' //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index','table','laydate','form'], function(){
    var $ = layui.$,table = layui.table,form = layui.form,laydate = layui.laydate;

    laydate.render({
      elem: '#starttime' //指定元素
    });

    laydate.render({
      elem: '#endtime' //指定元素
    });

    $.ajax({
        type: "get",
        url: "get_typelist",
        dataType: "json",
        async:false,
        success: function (res) {
            $.each(res.typelist, function (i, v) {
                $("#typeid").append("<option value='" + v.id + "'>" + v.title + "</option>");
            });
            layui.form.render("select");
        }
    });

    table.render({
      elem: '#dds-list'
      , url: 'lottery_company' //接口
        , cols: [[
          { field: 'number', title: '序号', width: 60,align: 'center' }
        , { field: 'companyname', title: '中标单位', minWidth: 100, align: 'left' }
        , { field: 'typename', title: '项目类型', minWidth: 100, align: 'center' }
        , { field: 'project_name', title: '项目名称', minWidth: 100, align: 'center' },
        , { field: 'lun', title: '轮次',width:120,align: 'center', templet: '#tpl_lunci' }
        , { field: 'buyer', title: '采购人', minWidth:100 , align: 'center' }
        , { field: 'datetime', title: '中标时间', width: 170, align: 'center' }
        , { title: '确认表', width: 95, align: 'center', fixed: 'right', toolbar: '#table-content-list' }
      ]]
      , page: true
      , request: {
        pageName: 'pageindex', //页码的参数名称，默认：page
        limitName: 'pagesize' //每页数据量的参数名，默认：limit
      }
      , limit: 20
      , limits: [20, 50, 100]
      , text: {
        none: '暂无相关数据'
      }
    });

    //监听搜索
    form.on('submit(btn_search)', function(data){
        var field = data.field;
        console.log(field);
      //执行重载
      table.reload('dds-list', {
        where: field
      });
    });

    //监听操作
    var active = {
      refresh: function () {
        table.reload('dds-list');
      }
    }; 

    $('.layui-btn.layuiadmin-btn-list').on('click', function(){
      var type = $(this).data('type');
      active[type] ? active[type].call(this) : '';
    });

    //监听工具条
    table.on('tool(dds-list)', function(obj){
      var data = obj.data;
        if(obj.event === 'queren'){
            window.open('lottery_confirm.html?id='+data.id);
        } 
    });

  });
  </script>
</body>
</html>
